import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

import city from './cityState'

export default new Vuex.Store({
  state: {
    city: city,
    buyflag:false
  },
  actions: {
    getCity(context,name){
      context.commit('pickCity',name)
    }
  },
  mutations: {
   pickCity(state,name){
    this.state.city=name
    try{
       localStorage.city = name
    }catch(e){}
   },
   changbuyflag(state,flag){
    this.state.buyflag=flag
   },
    buydata(state,data){
      this.state.buydata=data
    }
  },
  getters: {
    foo(state){
       return state.buyflag
    }
  }
})